Repository navigation
Conversation
`truncate_for_display` split the body on "\n", so the empty string
after a final newline counted as a line. Tool output that exactly fit
the preview (10 lines ending in "\n", typical stdout) reported
hidden=1, and the CLI printed "+1 more line; run /show N to expand"
with nothing to expand. The collapsed preview (`head_lines=0`) counted
"a\nb\n" as 3 lines but "a\nb" as 2.
Both paths now share `_lines()`, which drops the newline that ends the
last line before splitting; a genuinely blank last line ("a\n\n")
still counts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
XAE-A-Xii
force-pushed
the
fix/cli-tool-result-trailing-newline
branch
from
December 5, 2026 12:15
1cc2b0d to
738e7c4
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The CLI's inline tool-result preview counted a trailing newline as a hidden line.
truncate_for_display(deeptutor_cli/_tool_result.py) split the body on"\n", so the empty string after a final newline counted as a line. Tool output that exactly fits the preview, for example 10 lines ending in\n(which is how stdout usually ends), reportedhidden=1, andcommon.py:_render_tool_resultprinted+1 more line; run /show N to expandwith nothing left to expand. The collapsed preview (head_lines=0) disagreed with itself too:"a\nb\n"counted 3 lines, but"a\nb"counted 2.Both paths now share a small
_lines()helper that drops the newline ending the last line before splitting. A genuinely blank last line still counts ("a\n\n"→ 2), and the visible preview text is unchanged apart from that trailing newline.Related Issues
Module(s) Affected
agentsapiconfigcoreknowledgeloggingservicestoolsutilsweb(Frontend)docs(Documentation)scriptstestsdeeptutor_cliChecklist
dev(notmain— see the base-branch selector above).pre-commit run --all-filesand fixed any issues.Additional Notes
There were no tests for
truncate_for_display, so this addstests/cli/test_tool_result.pywith four cases:Before the fix all 4 fail. Mutations are caught too: dropping the
removesuffixfails 4, and putting back the old_line_countfails 2.pre-commit run --fileson both changed files passes every hook.--all-filesfailsmypyondevitself inservices/embedding/adapters/volcengine.py, from #1015, which this PR doesn't touch.🤖 Generated with Claude Code